package com.demo.algorithm.thread;

import cn.hutool.core.util.StrUtil;

import java.util.concurrent.CompletableFuture;

/**
 * 异步编程，串行关系的异步
 */
public class CompletableFutureDemo {
    public static void main(String[] args) {
        getSupplyAsync();
    }

    public static void getSupplyAsync() {
        CompletableFuture<String> f0 = CompletableFuture.supplyAsync(
                () -> "Hello World")              //①
                .thenApply(s -> s + StrUtil.SPACE + "QQ")        //②依赖1的结果
                .thenApply(String::toUpperCase);//③依赖2的执行结果
        System.out.println(f0.join());
    }
}
